/**
 * Critical CSS - Above-the-fold styles for fast initial render
 * This file contains only essential styles needed for initial page load
 */

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    margin: 0;
    padding: 0;
    background-color: #0a0a0a !important;
    color: #f8f9fa !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Dark theme immediate application */
.dark-theme {
    background-color: #0a0a0a !important;
    color: #f8f9fa !important;
}

/* Container layout */
.container, .container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Main layout structure */
.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header/Topbar critical styles */
.topbar {
    background-color: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Navigation tabs critical styles */
.nav-tabs {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.nav-tabs .nav-link {
    color: #94a3b8;
    border: none;
    padding: 0.75rem 1.5rem;
    transition: color 0.2s;
}

.nav-tabs .nav-link.active {
    color: #f8f9fa;
    background-color: transparent;
    border-bottom: 2px solid #667eea;
}

/* Loading states */
.htmx-request .htmx-indicator {
    opacity: 1 !important;
}

.spinner-border {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: text-bottom;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Form controls critical styles */
.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.375rem;
    color: #f8f9fa;
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
    outline: 0;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Button critical styles */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    color: #fff;
    background-color: #667eea;
    border-color: #667eea;
}

.btn-primary:hover:not(:disabled) {
    background-color: #5a65d1;
    border-color: #5a65d1;
}

.btn-secondary {
    color: #fff;
    background-color: #475569;
    border-color: #475569;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Card critical styles */
.card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.card-body {
    padding: 1.25rem;
}

/* Visibility utilities */
.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

/* Text utilities */
.text-center {
    text-align: center !important;
}

.text-muted {
    color: #64748b !important;
}

/* Spacing utilities */
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }

.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }

.p-3 { padding: 1rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }

/* Alert critical styles */
.alert {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

.alert-danger {
    color: #e57373;
    background-color: rgba(229, 115, 115, 0.1);
    border-color: rgba(229, 115, 115, 0.2);
}

/* Hide content until styles load */
.no-fouc {
    visibility: hidden;
    opacity: 0;
}

body.styles-loaded .no-fouc {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease;
}
